package com.ssy.lingxi.member.merchant.controller.paas;

import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.member.merchant.api.model.vo.paas.*;
import com.ssy.lingxi.member.merchant.service.paas.IPaasLevelRightCreditService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * 系统初始化 - 设置基础的升级规则、等级、权益、信用等规则
 * @author 万宁
 * @version 2.0.0
 * @date 2020-08-23
 */
@RestController
@RequestMapping("/paas/member/base")
public class BaseLevelRightCreditController {

    @Resource
    private IPaasLevelRightCreditService baseLevelRightCreditService;

    /**
     * 修改会员权益状态
     * @param configVO 接口参数
     * @return 状态码
     */
    @RequestMapping(value = "/right/update/status", method = RequestMethod.POST)
    public Wrapper<Void> updateBaseRightStatus(@RequestBody @Valid BaseRightConfigStatusVO configVO) {
        return baseLevelRightCreditService.updateBaseRightStatus(configVO);
    }

    /**
     * 更改会员升级规则设置的状态
     * @param configVO 接口参数
     * @return 状态码
     */
    @RequestMapping(value = "/level/rule/update/status", method = RequestMethod.POST)
    public Wrapper<Void> updateBaseLevelRuleConfigStatus(@RequestBody @Valid BaseLevelRuleStatusVO configVO) {
        return baseLevelRightCreditService.updateBaseLevelRuleConfigStatus(configVO);
    }

    /**
     * 新增或修改基础会员等级配置（及关联的角色）
     * @param configVO 接口参数
     * @return 状态码
     */
    @RequestMapping(value = "/level/config/update/insert", method = RequestMethod.POST)
    public Wrapper<Void> updateOrInsertBaseLevelConfig(@RequestBody @Valid BaseLevelConfigVO configVO) {
        return baseLevelRightCreditService.updateOrInsertBaseLevelConfig(configVO);
    }

    /**
     * 查询所有基础会员等级设置（V2待删除）
     * @return 基础等级设置列表
     */
    @RequestMapping(value = "/level/config/list", method = RequestMethod.GET)
    public Wrapper<List<BaseLevelConfigVO>> listBaseLevelConfig() {
        return baseLevelRightCreditService.listBaseLevelConfig();
    }

    /**
     * 更新会员等级状态
     * @param deleteVO 接口参数
     * @return 状态码
     */
    @RequestMapping(value = "/level/config/delete", method = RequestMethod.POST)
    public Wrapper<Void> deleteBaseLevelConfigStatus(@RequestBody @Valid BaseLevelConfigDeleteVO deleteVO) {
        return baseLevelRightCreditService.deleteBaseLevelConfig(deleteVO);
    }

    /**
     * 更新会员等级状态
     * @param updateVO 接口参数
     * @return 状态码
     */
    @RequestMapping(value = "/level/config/update/status", method = RequestMethod.POST)
    public Wrapper<Void> updateBaseLevelConfigStatus(@RequestBody @Valid BaseLevelConfigStatusVO updateVO) {
        return baseLevelRightCreditService.updateBaseLevelConfigStatus(updateVO);
    }

    /**
     * 更改会员信用评估规则权重
     * @param pointVO 接口参数
     * @return 状态码
     */
    @RequestMapping(value = "/credit/update/point", method = RequestMethod.POST)
    public Wrapper<Void> updateMemberCreditConfigPoint(@RequestBody @Valid MemberCreditConfigVO pointVO) {
        return baseLevelRightCreditService.updateMemberCreditConfigPoint(pointVO);
    }

    /**
     * 更改会员信用评估规则状态
     * @param pointVO 接口参数
     * @return 状态码
     */
    @RequestMapping(value = "/credit/update/status", method = RequestMethod.POST)
    public Wrapper<Void> updateMemberCreditConfigStatus(@RequestBody @Valid MemberCreditConfigVO pointVO) {
        return baseLevelRightCreditService.updateMemberCreditConfigStatus(pointVO);
    }
}
